import com.demo.component.ArticleController;
import com.demo.component.UserComponent;
import com.demo.controller.StudentController;
import com.demo.controller.UserAdviceController;
import com.demo.controller.UserController;
import com.demo.model.Student;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

import java.security.cert.X509Certificate;

/**
 * @author krystal
 * @date 2023/3/5 21:53
 */
public class App {
    public static void main(String[] args) {
        ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
        System.out.println("得到spring之后");
//        //1、得到Spring对象
//        ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
//        //BeanFactory beanFactory=new XmlBeanFactory(new ClassPathResource("spring-config.xml"));
//        //2、从Spring中取出Bean对象
//        //User user= (User) context.getBean("user");
//        User user=context.getBean("user",User.class);
//        //3、使用Bean
//        System.out.println(user.exo());

//        ArticleController articleController=context.getBean("articleController",ArticleController.class);
//        System.out.println(articleController.sayHi());

//        UserComponent userComponent=context.getBean("userComponent",UserComponent.class);
//        System.out.println(userComponent.sayHi());

//        User user=context.getBean("user",User.class);
//        System.out.println(user.exo());

//        Student student=context.getBean("s1",Student.class);
//        System.out.println(student);

//        Student student=context.getBean("student",Student.class);
//        System.out.println(student);

//        StudentController studentController=context.getBean("studentController",StudentController.class);
//        studentController.sayHi();

        UserController userController=context.getBean("userController",UserController.class);
        userController.getUser();

        UserAdviceController userAdviceController=context.getBean("userAdviceController",UserAdviceController.class);
        userAdviceController.getUser();

    }
}
